package cn.com.header.zbpk.base.controller;

import cn.com.header.core.support.web.JsonViewData;
import cn.com.header.zbpk.base.entity.Subject;
import cn.com.header.zbpk.base.service.ISubjectService;
import cn.com.header.zbpk.web.CommonController;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 学科控制器
 * @author Yuanyifeng
 * @date 2017-11-21
 * @time 17:41
 */
@RestController
@RequestMapping(value = "/base/subject")
public class SubjectController extends CommonController{
    @Autowired
    private ISubjectService iSubjectService;
    /**
     * 根据学段获取学科
     * @return
     */
    @RequestMapping(value="getSubjectBySection/{sectionId}")
    public JsonViewData getSubjectBySection(@PathVariable("sectionId")Long sectionId){
        Map<String, Object> resultMap = Maps.newHashMapWithExpectedSize(1);
        Subject subject=new Subject();
        subject.setSectionId(sectionId);
        List<Subject> subjectList=iSubjectService.loads(subject,false, Sets.newHashSet("id","name"));
        resultMap.put("subjectList",subjectList);
        return setJsonViewData(resultMap);
    }
}
